#! /bin/bash
export LANG=zh_CN.UTF-8
PRESTO_HOME=/export/server/presto/bin/presto


${PRESTO_HOME} --catalog hive --server 192.168.88.80:8090 --execute "

--稽核上层表数据量
select 1/count(*) from hive.edu_dm.ydh_dm_check_wide_timecnt;

delete from hive.edu_rpt.ydh_rpt_studying_timecnt  where 1=1;
insert into hive.edu_rpt.ydh_rpt_studying_timecnt
select create_date,
       class_id,
       time_type,
       dt,
       studying_cnt,
       studying_pct
from hive.edu_dm.ydh_dm_check_wide_timecnt
;
delete from hive.edu_rpt.ydh_rpt_late_timecnt  where 1=1;
insert into hive.edu_rpt.ydh_rpt_late_timecnt
select create_date,
       class_id,
       time_type,
       dt,
       late_cnt,
       late_pct
from hive.edu_dm.ydh_dm_check_wide_timecnt
;
delete from hive.edu_rpt.ydh_rpt_leave_timecnt  where 1=1;
insert into hive.edu_rpt.ydh_rpt_leave_timecnt
select create_date,
       class_id,
       time_type,
       dt,
       leave_cnt,
       leave_pct
from hive.edu_dm.ydh_dm_check_wide_timecnt
;
delete from hive.edu_rpt.ydh_rpt_truant_timecnt  where 1=1;
insert into hive.edu_rpt.ydh_rpt_truant_timecnt
select create_date,
       class_id,
       time_type,
       dt,
       truant_cnt,
       truant_pct
from hive.edu_dm.ydh_dm_check_wide_timecnt
;
"
a=$?
if [ ${a} -eq 0 ];then 
	echo 'Program running status return code:' ${a}
	echo '=============================打完收工！================================='
else 
	echo 'Program running status return code:' ${a}
	echo '=============================程序出BUG咯！=============================='
	fi